package com.fireXXX.job.analysis.crawler.boss;

import com.fireXXX.job.analysis.crawler.boss.data.OriginCompany;
import com.fireXXX.job.analysis.crawler.boss.data.OriginJobItem;
import com.fireXXX.job.analysis.data.api.job.Company;
import com.fireXXX.job.analysis.data.api.job.Job;
import com.fireXXX.job.analysis.data.api.job.SourceTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@Component
@Slf4j
public class CompanyParser {

    public List<Company> parse(List<OriginCompany> items) {
        return Optional.ofNullable(items).orElse(Collections.emptyList()).stream().map(item -> {
            Company company = new Company();
            company.setSource(SourceTypeEnum.BOSS);
            company.setBenefits(item.getBenefits());
            company.setEmployeeNumber(item.getEmployeeNumber());
            company.setName(item.getName());
            company.setPublicStep(item.getPublicStep());
            company.setIndustry(item.getIndustry());

            return company;
        }).collect(Collectors.toList());
    }

}
